package com.wangzhenyu.common.base

import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.viewbinding.ViewBinding

abstract class BaseVMFragment<VM : ViewModel> : Fragment() {

    //ViewModel
    protected lateinit var viewModel: VM

    protected abstract fun getSubVmClass(): Class<VM>

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        initViewModel()
    }

    private fun initViewModel() {
        viewModel = ViewModelProvider(this)[getSubVmClass()]
    }


}